<?php
namespace app\index\controller;
use think\Db;
class Index extends Base{
    public function index(){
        $operation=Db::name('operation')->where('id',1)->find();
        $this->assign('operation',$operation);
        return $this->fetch();
    }
    public function ver_year(){
    	$toyear=date('Y',time());
        return json(['code' => 200,'toyear' =>$toyear]);exit();
    }
    public function versions(){
    	$year=input("param.yearid");
    	$yearf=strtotime($year.'-01-01 00:00:00');
    	$yeart=strtotime($year.'-12-31 23:59:59');
        $version=Db::name('version')->where('time','<',$yeart)->where('time','>',$yearf)->order('id asc')->select();
        if($version){
            return json(['code' => 200, 'version' =>$version]);exit();
        }else{
            return json(['code' => 500, 'msg' => '暂无数据']);exit();
        }
    }
    public function updates(){
        $updates=Db::name('update')->where('v_id',input("param.v_id"))->order('id desc')->select();
        if($updates){
            return json(['code' => 200, 'updates' =>$updates]);exit();
        }else{
            return json(['code' => 500, 'msg' => '暂无数据']);exit();
        }
    }
}
